//
//  MytabbarViewController.swift
//  MySwift
//
//  Created by nadyboy on 2018/12/13.
//  Copyright © 2018年 hjh. All rights reserved.
//

import UIKit

class MytabbarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        let homeVc = addChildVc(childVc:HomeViewController(),title: "首页", image: "shouye")
        let messageVc = addChildVc(childVc:MessageViewController(),title: "消息", image: "xiaoxi")
        let mineVc = addChildVc(childVc:MineViewController(),title: "我", image: "wode")
        
        addChild(homeVc)
        addChild(messageVc)
        addChild(mineVc)
    }
    
    func addChildVc(childVc:UIViewController,title:String,image:String?) -> (UIViewController) {
        let vc = childVc
        vc.title = title
        vc.tabBarItem.image = UIImage(named: image!)
        vc.tabBarItem.selectedImage = UIImage(named: image!)
        let nav = NavViewController.init(rootViewController: vc)
        return nav
    }

}
